
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Unit.h>
#include <Length.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Length_compare)
{
        TEST(check compare result via operator==, 2 same Length and unit)
        {
                Length oneLen(3,MILE);
                Length twoLen(3,MILE);
                ASSERT_TRUE(oneLen == twoLen);
        }
        TEST(check compare result of 2 Length via operator== , same Length but different unit)
        {
                Length oneLen(3,MILE);
                Length twoLen(3*1760,YARD);
                ASSERT_TRUE(oneLen == twoLen);
        }

        TEST(check compare result of 2 Length via operator==, different Length)
        {
                Length oneLen(3,MILE);
                Length twoLen(3*1760+1,YARD);
                ASSERT_FALSE(oneLen == twoLen);
        }

        TEST(check compare result of 2 Length via operator!=, different Length)
        {
                Length oneLen(3,MILE);
                Length twoLen(3*1760+1,YARD);
                ASSERT_TRUE(oneLen != twoLen);
        }

        TEST(check compare result of 2 Length via operator!= , same Length but different unit)
        {
                Length oneLen(3,MILE);
                Length twoLen(3*1760,YARD);
                ASSERT_FALSE(oneLen != twoLen);
        }
};

FIXTURE(Length_operatorPlus)
{
        TEST(check value of 2 Length operator+, same unit)
        {
                Length oneLen(3,MILE);
                Length twoLen(5,MILE);
                Length threeLen(8,MILE);
                ASSERT_TRUE(threeLen == oneLen + twoLen );
        }

        TEST(check value of 2 Length operator+, different unit)
        {
                Length oneLen(3*1760,YARD);
                Length twoLen(5,MILE);
                Length threeLen(8,MILE);
                ASSERT_TRUE(threeLen == oneLen + twoLen );
        }

        TEST(check value of 2 Length operator+, different unit)
        {
                Length oneLen(3*3*1760,FEET);
                Length twoLen(5,MILE);
                Length threeLen(8,MILE);
                ASSERT_TRUE(threeLen == oneLen + twoLen );
        }
};

FIXTURE(Length_outString)
{
        TEST(check Unit out string)
        {
                Length len(3,MILE);
                std::string str("3MILE");
                ASSERT_EQ(str,len.toString());
        }

        TEST(check Unit out string, mixed units)
        {
                Length len1(3,MILE);
                Length len2(1020,YARD);
                Length total = len1 + len2;
                std::string str("3MILE1020YARD");
                ASSERT_EQ(str,total.toString());
        }


        TEST(check Unit out string, mixed units)
        {
                Length len1(3,MILE);
                Length len2(2,FEET);
                Length total = len1 + len2;
                std::string str("3MILE2FEET");
                ASSERT_EQ(str,total.toString());
        }

        TEST(check Unit out string, mixed units)
        {
                Length len1(3,MILE);
                Length len2(2,YARD);
                Length len3(9,FEET);
                Length total = len1 + len2 + len3;
                std::string str("3MILE5YARD");
                ASSERT_EQ(str,total.toString());
        }
};

FIXTURE(Length_outString_minUnit)
{
        TEST(check Unit out string)
        {
                Length len(3,MILE);
                std::string str("15840 FEET");
                ASSERT_EQ(str,len.toMinUnitString());
        }

        TEST(check Unit out string, mixed units)
        {
                Length len1(3,MILE);
                Length len2(1020,YARD);
                Length total = len1 + len2;
                std::string str("18900 FEET");
                ASSERT_EQ(str,total.toMinUnitString());
        }
};

